/**
 * 功能描述�?
 */
define(function (require, exports, module) {
    //引入视图基类
    var ELView = require("elview");
    var aw = require("ajaxwrapper");
    //assets
    var template = require("./assets/tpl/nonmemcheckoutconfirm_main.tpl");
    require("./assets/css/nonmemcheckoutconfirm_main.css");

    //business

    //component
    var nonMemSetlConfSubnav = require("./component/nonMemSetlConfSubnav");
    var nonMemSetlConfGrid = require("./component/nonMemSetlConfGrid");
    var onCreditForm = require("./component/onCreditForm");
    var nonMemCheckOutForm = require("../../nonmemcheckout/src/component/nonMemCheckOutForm");
    var renderDetailForm = require("../../nonmemcheckout/src/component/renderDetailForm");
    var settleEditGridOne = require("../../nonmemcheckout/src/component/settleEditGridOne");
    var settleEditGridTwo = require("../../nonmemcheckout/src/component/settleEditGridTwo");
    var settleForm = require("../../checkoutsettlement/src/component/settleForm");
    //constant

    //handler
    var gridHandler = require("./handler/gridHandler");
    var subnavEvents = require("../../nonmemcheckout/src/handler/subnavEvents");
    var formHandler = require("../../nonmemcheckout/src/handler/formHandler");
    var total = require("../../nonmemcheckout/src/handler/total");
    var detailEvents = require("../../checkoutsettlement/src/handler/detailEvents");
    
    //store

    var App = ELView.extend({
        attrs: {
            template: template
        },
        
        member:false,
        detail:false,
        handler : {
        	gridHandler : gridHandler,
        	subnavHandler : subnavEvents,
        	formHandler:formHandler,
        	total:total,
        },
        detailHandler:detailEvents,
        initComponent: function (params, widget) {
        	nonMemSetlConfSubnav.initComponent(params, widget);
        	nonMemSetlConfGrid.initComponent(params, widget);
        	onCreditForm.initComponent(params, widget);
        	nonMemCheckOutForm.initComponent(params, widget);
        	renderDetailForm.initComponent(params, widget);
        	settleEditGridOne.initComponent(params, widget);
        	settleEditGridTwo.initComponent(params, widget);
        	settleForm.initComponent(params, widget);
        },
        afterInitComponent: function (params, widget) {
			aw.ajax({
				url:"api/baseprice/getprice",
				dataType:"json",
				success:function(datas){
					widget.set("basePrice",datas);
					widget.get("grid").refresh();
				}
			})
        	
        },
        toGrid:function(){
		    $(".J-endGrid").empty();
		    $(".J-total").empty();
		    this.member = false;
		    this.detail = false;
		    this.get("totalGrid").setDisabled(false);
		    this.hide([".J-form", ".J-total", ".J-endGrid",".J-detailForm",".J-onCreditForm"]).show([".J-grid"]);
		    this.get("subnav").show(["paymentMethod","servicePoint", "status", "checkOutDate"]).hide(["return","totalprint"]);
        },
        toSubGrid:function(){
        	this.show([".J-form", ".J-total", ".J-endGrid"]).hide([".J-grid",".J-detailForm"]);
        	this.get("subnav").hide(["servicePoint", "status", "checkOutDate"]).show(["return","totalprint"]);
        	if(this.detail){
        		this.get("subnav");
        	}
        },
        toForm:function(){
        	this.show([".J-detailForm"]).hide([".J-form",".J-endGrid",".J-total",".J-grid"]);
        	this.get("subnav").hide(["return", "servicePoint", "status", "checkOutDate","totalprint"]).show("print");
        }
    });

    module.exports = App;
});
